﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraReports.UI;

namespace WmsApp.ReportFile
{
    public partial class XtraReportOutStoreBill
    {
        private void DataBinding()
        {
            this.tableCell12.Text = (String)GetDataTableMainObjectByField("Department");
            this.tableCell14.Text = (String)GetDataTableMainObjectByField("RequisitionNo");
            this.tableCell20.Text = (String)GetDataTableMainObjectByField("Purpose");
            this.tableCell17.Text = (String)GetDataTableMainObjectByField("ProjectNo");
            this.tableCell19.Text = (String)GetDataTableMainObjectByField("BillID");
            this.tableCell10.DataBindings.Add("Text", this.DataTableMain, "OutBillDate", "{0:yyyy'年'M'月'd'日'}");
            this.xrTableCell16.DataBindings.Add("Text", this.DataTableMain, "GetName");

            this.DataSource = this.DataTableDetail;

            //汇总信息
            this.xrLabel10.Summary.Func = SummaryFunc.Sum;
            this.xrLabel10.Summary.Running = SummaryRunning.Report;
            this.xrLabel10.DataBindings.Add("Text", this.DataSource, "Quantity", "{0:0.000}");  //数量
        }

        private object GetDataTableMainObjectByField(string field)
        {
            if (DataTableMain == null || DataTableMain.Rows.Count == 0)
                return null;
            if (DataTableMain.Rows[0][field] == DBNull.Value)
                return null;
            return DataTableMain.Rows[0][field];
        }

        public System.Data.DataTable DataTableMain { get; set; }

        public System.Data.DataTable DataTableDetail { get; set; }
    }
}
